package com.settlement.system.model.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.settlement.system.common.base.BaseEntity;
import com.settlement.system.common.enums.AuditErrorRecordStatusEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
* <p>
* 转换核销单失败记录表
* </p>
*
* @author huangrensen
* @since 2024-08-26
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AuditErrorRecord extends BaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
    * ID
    */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;


    /**
    * 数据类型
    */
    private Integer dataType;
    @TableField(exist = false)
    private String dataTypeName;


    /**
    * 数据关联字段
    */
    private String dataId;


    /**
    * 账单日期集合
    */
    private String businessDateStr;


    /**
    * 店铺ID
    */
    private Long storeId;
    @TableField(exist = false)
    private String storeName;


    /**
    * 是否需要更新业务日期(0 不需要 1 需要)
    */
    private Integer needUpdateBusinessDate = 0;
    @TableField(exist = false)
    private String needUpdateBusinessDateName;

    /**
    * 是否删除
    */
    private Integer deleted = 0;


    /**
    * 备注
    */
    private String remark;

    /**
     * 尝试次数
     */
    private Integer tryNumber = 1;

    /**
    * 状态
    */
    private Integer status = AuditErrorRecordStatusEnum.ERROR.getValue();
    @TableField(exist = false)
    private String statusName;

    // 截取长度超出范围的字段
    public void cutString() {
        if (this.remark != null && this.remark.length() > 2000) {
            this.remark = this.remark.substring(0, 2000);
        }
    }
}
